# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Mosra <mosra@centrum.cz>

pkgname=magnum
pkgver=2020.06
pkgrel=3
pkgdesc='C++11/C++14 graphics middleware for games and data visualization'
arch=(loong64 x86_64)
url='https://magnum.graphics'
license=(MIT)
depends=('corrade>=2020.06' glfw openal sdl2 vulkan-icd-loader)
makedepends=(cmake git)
optdepends=('magnum-plugins: import and export features')
source=("git+https://github.com/mosra/magnum#commit=fac6f4da261930c7035bf51f66091e350905720b") # tag: v2020.06
sha256sums=('SKIP')

prepare() {
# Fix build with recent cmake
  sed -e '/CONFIG/d' -i $pkgname/modules/FindOpenAL.cmake
}

build() {
  mkdir -p build
  cd build
  cmake ../$pkgname \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS -ffat-lto-objects -Wfatal-errors" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_AL_INFO=ON \
    -DWITH_ANYAUDIOIMPORTER=ON \
    -DWITH_ANYIMAGECONVERTER=ON \
    -DWITH_ANYIMAGEIMPORTER=ON \
    -DWITH_ANYSCENEIMPORTER=ON \
    -DWITH_AUDIO=ON \
    -DWITH_DISTANCEFIELDCONVERTER=ON \
    -DWITH_GLXAPPLICATION=ON \
    -DWITH_GLXCONTEXT=ON \
    -DWITH_IMAGECONVERTER=ON \
    -DWITH_MAGNUMFONT=ON \
    -DWITH_MAGNUMFONTCONVERTER=ON \
    -DWITH_OBJIMPORTER=ON \
    -DWITH_FONTCONVERTER=ON \
    -DWITH_GL_INFO=ON \
    -DWITH_GLFWAPPLICATION=ON \
    -DWITH_SDL2APPLICATION=ON \
    -DWITH_TGAIMAGECONVERTER=ON \
    -DWITH_TGAIMPORTER=ON \
    -DWITH_VK=ON \
    -DWITH_WAVAUDIOIMPORTER=ON \
    -DWITH_WINDOWLESSGLXAPPLICATION=ON
  make
}

package() {
  make DESTDIR="$pkgdir" -C build install
  install -Dm644 $pkgname/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
}
